{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "% matplotlib inline\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "death_records = pd.read_csv('DeathRecords.csv')\n",
    "death_records_columns = death_records.columns\n",
    "death_records = death_records[death_records['EducationReportingFlag'] == 1]\n",
    "death_records = death_records.drop(['EducationReportingFlag','Education1989Revision'], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19229 10020 27052\n"
     ]
    }
   ],
   "source": [
    "gun_homicides = death_records[death_records['CauseRecode113']==128]\n",
    "gun_suicides = death_records[death_records['CauseRecode113']==125]\n",
    "\n",
    "gun_deaths = pd.concat([gun_homicides,gun_suicides])\n",
    "gun_deaths['CauseRecode113'] = gun_deaths['CauseRecode113'].map({128: 1, 125: 0})\n",
    "gun_deaths = gun_deaths.drop(['CauseRecode39','CauseRecode358',\n",
    "                              'InfantCauseRecode130','PlaceOfDeathAndDecedentsStatus',\n",
    "                             'MethodOfDisposition','Autopsy',\n",
    "                             'NumberOfEntityAxisConditions',\n",
    "                             'NumberOfRecordAxisConditions','AgeRecode27',\n",
    "                             'AgeRecode52','AgeSubstitutionFlag','AgeType',\n",
    "                             'InfantAgeRecode22','CurrentDataYear',\n",
    "                             'MannerOfDeath','Icd10Code','Age'],axis=1)\n",
    "gun_deaths=gun_deaths.rename(columns = {'CauseRecode113':'Homicide_1',\n",
    "                                        'Education2003Revision':'Edu',\n",
    "                                       'MonthOfDeath':'DeathMonth',\n",
    "                                        'DayOfWeekOfDeath':'DeathDay',\n",
    "                                        'AgeRecode12': 'Age'\n",
    "                                       })\n",
    "\n",
    "gun_deaths = gun_deaths[gun_deaths['RaceImputationFlag']==0]\n",
    "\n",
    "gun_deaths = gun_deaths.drop(['RaceImputationFlag'],axis=1)\n",
    "gun_deaths = gun_deaths[gun_deaths['InjuryAtWork'] != 'U']\n",
    "gun_deaths['InjuryAtWork'] = gun_deaths['InjuryAtWork'].map({'Y': 1, 'N': 0})\n",
    "gun_deaths['Sex'] = gun_deaths['Sex'].map({'M':0, 'F':1})\n",
    "gun_deaths = gun_deaths[gun_deaths['BridgedRaceFlag']==0]\n",
    "gun_deaths = gun_deaths.drop('BridgedRaceFlag',axis=1)\n",
    "gun_deaths = gun_deaths[gun_deaths['Edu'] < 9]\n",
    "gun_deaths = gun_deaths[gun_deaths['MaritalStatus'] != 'U']\n",
    "gun_deaths = gun_deaths[gun_deaths['Age'] < 12]\n",
    "gun_deaths = gun_deaths[gun_deaths['HispanicOrigin'] < 996]\n",
    "gun_deaths = gun_deaths[gun_deaths['HispanicOriginRaceRecode'] < 9]\n",
    "gun_deaths['Intercepts'] = np.ones(len(gun_deaths))\n",
    "\n",
    "resident_dummies = pd.get_dummies(gun_deaths['ResidentStatus'], prefix='ResidentStatus')\n",
    "#residence bassline is 1- resident of state/county where death occurred\n",
    "edu_dummies = pd.get_dummies(gun_deaths['Edu'], prefix='Edu')\n",
    "#edu bassline is 1- 8th grade or less\n",
    "age_dummies = pd.get_dummies(gun_deaths['Age'], prefix='Age')\n",
    "#age bassline is 1- less than a year old\n",
    "marital_dummies = pd.get_dummies(gun_deaths['MaritalStatus'], prefix='MaritalStatus')\n",
    "#marital bassline is D-divorced\n",
    "injury_dummies = pd.get_dummies(gun_deaths['PlaceOfInjury'], prefix='PlaceOfInjury')\n",
    "#injury bassline is 0- occurred at home\n",
    "activity_dummies = pd.get_dummies(gun_deaths['ActivityCode'],prefix='ActivityCode')\n",
    "#activity bassline is 0- occurred during sports\n",
    "race_dummies = pd.get_dummies(gun_deaths['Race'],prefix='Race')\n",
    "#race bassline is 1-white\n",
    "race3_dummies = pd.get_dummies(gun_deaths['RaceRecode3'],prefix='RaceRecode3')\n",
    "#race3 bassline is 1-white\n",
    "race5_dummies = pd.get_dummies(gun_deaths['RaceRecode5'],prefix='RaceRecode5')\n",
    "#race5 bassline is 1-White\n",
    "hisp_dummies = pd.get_dummies(gun_deaths['HispanicOrigin'],prefix='HispanicOrigin')\n",
    "#hispanic bassline is 100-nonhispanic\n",
    "hisprecode_dummies = pd.get_dummies(gun_deaths['HispanicOriginRaceRecode'],prefix='HispanicOriginRaceRecode')\n",
    "#hispanicrecode bassline is 1-mexican\n",
    "\n",
    "\n",
    "cols_to_keep = ['Id', 'Sex', 'Intercepts', 'DeathMonth', 'DeathDay', 'Homicide_1']\n",
    "dummy_data = gun_deaths[cols_to_keep].join(resident_dummies.ix[:, 'ResidentStatus_2':])\n",
    "dummy_data = dummy_data.join(edu_dummies.ix[:,'Edu_2':])\n",
    "dummy_data = dummy_data.join(age_dummies.ix[:,'Age_2':])\n",
    "dummy_data = dummy_data.join(marital_dummies.ix[:,'MaritalStatus_M':])\n",
    "dummy_data = dummy_data.join(injury_dummies.ix[:,'PlaceOfInjury_2':])\n",
    "dummy_data = dummy_data.join(activity_dummies.ix[:,'ActivityCode_2':])\n",
    "dummy_data = dummy_data.join(race_dummies.ix[:,'Race_2':])\n",
    "dummy_data = dummy_data.join(race3_dummies.ix[:,'RaceRecode3_2':])\n",
    "dummy_data = dummy_data.join(race5_dummies.ix[:,'RaceRecode5_2':])\n",
    "dummy_data = dummy_data.join(hisp_dummies.ix[:,'HispanicOrigin_200':])\n",
    "dummy_data = dummy_data.join(hisprecode_dummies.ix[:,'HispanicOriginRaceRecode_2':])\n",
    "\n",
    "print(len(gun_suicides),len(gun_homicides), len(dummy_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.857565303105\n",
      "0.903800278006\n",
      "[[4923  430]\n",
      " [ 726 2037]]\n",
      "             precision    recall  f1-score   support\n",
      "\n",
      "          0       0.87      0.92      0.89      5353\n",
      "          1       0.83      0.74      0.78      2763\n",
      "\n",
      "avg / total       0.86      0.86      0.86      8116\n",
      "\n",
      "[ 0.84331116  0.86289727  0.85809313  0.88913525  0.87620103  0.85175601\n",
      "  0.85249538  0.86871302  0.81360947  0.85465976]\n",
      "0.857087147668\n",
      "Intercepts: -0.0936913449694\n",
      "Sex: 0.917405507831\n",
      "SameState: 0.156666735575\n",
      "SameCountry: 0.198925445639\n",
      "ForeignBorn: 1.22444707174\n",
      "9_12grade: 0.0490647998844\n",
      "HS_grad: -0.462435221749\n",
      "CollegeCredit: -0.83526615299\n",
      "Assoc_Deg: -0.798807361804\n",
      "Bach_Deg: -1.26339755484\n",
      "Master_Deg: -1.23036426837\n",
      "Doctorate: -1.3609967354\n",
      "1_4_yr: 2.43174725116\n",
      "5_14_yr: 0.0408614977208\n",
      "15_24_yr: 0.144353582984\n",
      "25_34_yr: 0.321508880799\n",
      "35_44_yr: 0.141870051064\n",
      "45_54_yr: -0.234511887746\n",
      "55_64_yr: -0.607945744032\n",
      "65_74_yr: -0.914787564819\n",
      "75_84_yr: -1.22375671313\n",
      "85_plus_yr: -1.5679523081\n",
      "Married: -0.0386280098175\n",
      "Single: 0.35545897457\n",
      "Widowed: 0.147239775263\n",
      "school: 0.78302170668\n",
      "sports_area: -0.423184858202\n",
      "road: 1.62124371973\n",
      "trade_area: 0.78810363468\n",
      "industrial_area: 0.588985054308\n",
      "farm: -0.110515636127\n",
      "other: 0.479427210699\n",
      "unknown: 0.764360472227\n",
      "working: -0.115510851057\n",
      "resting: 0.600739689483\n",
      "other: -0.995330087754\n",
      "unknown: 0.23654084737\n",
      "puerto_rican: 0.274469724993\n",
      "cuban: -0.713962641594\n",
      "central_south_american: -0.22064642231\n",
      "other_unknown_hisp: -0.704806577555\n",
      "white: -1.80159262112\n",
      "black: 1.24305430828\n",
      "other: -0.504775503\n"
     ]
    }
   ],
   "source": [
    "from sklearn.cross_validation import train_test_split as tts\n",
    "\n",
    "features_list = ['Intercepts', 'ResidentStatus_2','ResidentStatus_3', 'ResidentStatus_4', \n",
    "'Edu_2', 'Edu_3', 'Edu_4', 'Edu_5', 'Edu_6', 'Edu_7', 'Edu_8',\n",
    "'Age_2', 'Age_3', 'Age_4', 'Age_5', 'Age_6', 'Age_7', 'Age_8','Age_9', 'Age_10', 'Age_11',\n",
    "'MaritalStatus_M', 'MaritalStatus_S', 'MaritalStatus_W',\n",
    "'PlaceOfInjury_2', 'PlaceOfInjury_3', 'PlaceOfInjury_4', 'PlaceOfInjury_5',\n",
    "'PlaceOfInjury_6', 'PlaceOfInjury_7', 'PlaceOfInjury_8', 'PlaceOfInjury_9',\n",
    "'ActivityCode_2', 'ActivityCode_4', 'ActivityCode_8', 'ActivityCode_9', \n",
    "'HispanicOriginRaceRecode_2', 'HispanicOriginRaceRecode_3',\n",
    "'HispanicOriginRaceRecode_4', 'HispanicOriginRaceRecode_5',\n",
    "'HispanicOriginRaceRecode_6', 'HispanicOriginRaceRecode_7',\n",
    "'HispanicOriginRaceRecode_8']\n",
    "\n",
    "X = dummy_data[['Intercepts','Sex', 'ResidentStatus_2','ResidentStatus_3', 'ResidentStatus_4', \n",
    "'Edu_2', 'Edu_3', 'Edu_4', 'Edu_5', 'Edu_6', 'Edu_7', 'Edu_8',\n",
    "'Age_2', 'Age_3', 'Age_4', 'Age_5', 'Age_6', 'Age_7', 'Age_8','Age_9', 'Age_10', 'Age_11',\n",
    "'MaritalStatus_M', 'MaritalStatus_S', 'MaritalStatus_W',\n",
    "'PlaceOfInjury_2', 'PlaceOfInjury_3', 'PlaceOfInjury_4', 'PlaceOfInjury_5',\n",
    "'PlaceOfInjury_6', 'PlaceOfInjury_7', 'PlaceOfInjury_8', 'PlaceOfInjury_9',\n",
    "'ActivityCode_2', 'ActivityCode_4', 'ActivityCode_8', 'ActivityCode_9', \n",
    "'HispanicOriginRaceRecode_2', 'HispanicOriginRaceRecode_3',\n",
    "'HispanicOriginRaceRecode_4', 'HispanicOriginRaceRecode_5',\n",
    "'HispanicOriginRaceRecode_6', 'HispanicOriginRaceRecode_7',\n",
    "'HispanicOriginRaceRecode_8']]\n",
    "\n",
    "\n",
    "\n",
    "x_vars = ['Intercepts','Sex', 'SameState','SameCountry', 'ForeignBorn', \n",
    "'9_12grade', 'HS_grad', 'CollegeCredit', 'Assoc_Deg', 'Bach_Deg', 'Master_Deg', 'Doctorate',\n",
    "'1_4_yr', '5_14_yr', '15_24_yr', '25_34_yr', '35_44_yr',\n",
    "          '45_54_yr', '55_64_yr','65_74_yr','75_84_yr', '85_plus_yr',\n",
    "'Married', 'Single', 'Widowed',\n",
    "'school', 'sports_area', 'road', 'trade_area',\n",
    "'industrial_area', 'farm', 'other', 'unknown',\n",
    "'working', 'resting', 'other', 'unknown', \n",
    "'puerto_rican', 'cuban',\n",
    "'central_south_american', 'other_unknown_hisp',\n",
    "'white', 'black',\n",
    "'other']\n",
    "\n",
    "y = dummy_data['Homicide_1']\n",
    "\n",
    "x_train, x_test, y_train, y_test = tts(X,y, test_size=0.30, random_state=42)\n",
    "\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn import metrics\n",
    "\n",
    "logit_model = LogisticRegression()\n",
    "logit_train_results = logit_model.fit(x_train, y_train)\n",
    "logit_test_results = logit_model.predict(x_test)\n",
    "logit_test_prob = logit_model.predict_proba(x_test)\n",
    "logit_model.score(x_test, y_test)\n",
    "\n",
    "print(metrics.accuracy_score(y_test, logit_test_results))\n",
    "print(metrics.roc_auc_score(y_test, logit_test_prob[:, 1]))\n",
    "\n",
    "print(metrics.confusion_matrix(y_test, logit_test_results))\n",
    "print(metrics.classification_report(y_test, logit_test_results))\n",
    "\n",
    "from sklearn.cross_validation import cross_val_score\n",
    "\n",
    "scores = cross_val_score(LogisticRegression(), X, y, scoring='accuracy', cv=10)\n",
    "print(scores)\n",
    "print(scores.mean())\n",
    "\n",
    "coefs = list(logit_train_results.coef_[0])\n",
    "\n",
    "var_coefs = []\n",
    "\n",
    "for i in range(len(x_vars)):\n",
    "    vc = str(x_vars[i]) + \": \" + str(coefs[i])\n",
    "    print(vc)\n",
    "    var_coefs.append(vc)\n",
    "    i+=1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "full = X.join(y).drop('Intercepts',axis=1)\n",
    "comparative_data = pd.melt(full)\n",
    "comparative_data\n",
    "freq_data = pd.crosstab(index=[comparative_data['value']], columns=[comparative_data['variable']])\n",
    "\n",
    "freq_data = freq_data.T\n",
    "freq_data.to_csv('deaths_comparison.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>value</th>\n",
       "      <th>0.0</th>\n",
       "      <th>1.0</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>variable</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>ActivityCode_2</th>\n",
       "      <td>27051</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ActivityCode_4</th>\n",
       "      <td>27034</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ActivityCode_8</th>\n",
       "      <td>27018</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ActivityCode_9</th>\n",
       "      <td>59</td>\n",
       "      <td>26993</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_10</th>\n",
       "      <td>25477</td>\n",
       "      <td>1575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_11</th>\n",
       "      <td>26268</td>\n",
       "      <td>784</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_2</th>\n",
       "      <td>27014</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_3</th>\n",
       "      <td>26766</td>\n",
       "      <td>286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_4</th>\n",
       "      <td>22088</td>\n",
       "      <td>4964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_5</th>\n",
       "      <td>21954</td>\n",
       "      <td>5098</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_6</th>\n",
       "      <td>23188</td>\n",
       "      <td>3864</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_7</th>\n",
       "      <td>22813</td>\n",
       "      <td>4239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_8</th>\n",
       "      <td>23306</td>\n",
       "      <td>3746</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age_9</th>\n",
       "      <td>24599</td>\n",
       "      <td>2453</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_2</th>\n",
       "      <td>22523</td>\n",
       "      <td>4529</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_3</th>\n",
       "      <td>15381</td>\n",
       "      <td>11671</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_4</th>\n",
       "      <td>22706</td>\n",
       "      <td>4346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_5</th>\n",
       "      <td>25330</td>\n",
       "      <td>1722</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_6</th>\n",
       "      <td>24576</td>\n",
       "      <td>2476</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_7</th>\n",
       "      <td>26257</td>\n",
       "      <td>795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Edu_8</th>\n",
       "      <td>26709</td>\n",
       "      <td>343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_2</th>\n",
       "      <td>26842</td>\n",
       "      <td>210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_3</th>\n",
       "      <td>26934</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_4</th>\n",
       "      <td>26889</td>\n",
       "      <td>163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_5</th>\n",
       "      <td>26833</td>\n",
       "      <td>219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_6</th>\n",
       "      <td>9032</td>\n",
       "      <td>18020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_7</th>\n",
       "      <td>20813</td>\n",
       "      <td>6239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HispanicOriginRaceRecode_8</th>\n",
       "      <td>26481</td>\n",
       "      <td>571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Homicide_1</th>\n",
       "      <td>17867</td>\n",
       "      <td>9185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MaritalStatus_M</th>\n",
       "      <td>18190</td>\n",
       "      <td>8862</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MaritalStatus_S</th>\n",
       "      <td>15229</td>\n",
       "      <td>11823</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MaritalStatus_W</th>\n",
       "      <td>25388</td>\n",
       "      <td>1664</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_2</th>\n",
       "      <td>26853</td>\n",
       "      <td>199</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_3</th>\n",
       "      <td>27025</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_4</th>\n",
       "      <td>23923</td>\n",
       "      <td>3129</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_5</th>\n",
       "      <td>26081</td>\n",
       "      <td>971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_6</th>\n",
       "      <td>26978</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_7</th>\n",
       "      <td>26911</td>\n",
       "      <td>141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_8</th>\n",
       "      <td>23127</td>\n",
       "      <td>3925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PlaceOfInjury_9</th>\n",
       "      <td>25662</td>\n",
       "      <td>1390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ResidentStatus_2</th>\n",
       "      <td>24260</td>\n",
       "      <td>2792</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ResidentStatus_3</th>\n",
       "      <td>26027</td>\n",
       "      <td>1025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ResidentStatus_4</th>\n",
       "      <td>27024</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sex</th>\n",
       "      <td>23133</td>\n",
       "      <td>3919</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "value                           0      1\n",
       "variable                                \n",
       "ActivityCode_2              27051      1\n",
       "ActivityCode_4              27034     18\n",
       "ActivityCode_8              27018     34\n",
       "ActivityCode_9                 59  26993\n",
       "Age_10                      25477   1575\n",
       "Age_11                      26268    784\n",
       "Age_2                       27014     38\n",
       "Age_3                       26766    286\n",
       "Age_4                       22088   4964\n",
       "Age_5                       21954   5098\n",
       "Age_6                       23188   3864\n",
       "Age_7                       22813   4239\n",
       "Age_8                       23306   3746\n",
       "Age_9                       24599   2453\n",
       "Edu_2                       22523   4529\n",
       "Edu_3                       15381  11671\n",
       "Edu_4                       22706   4346\n",
       "Edu_5                       25330   1722\n",
       "Edu_6                       24576   2476\n",
       "Edu_7                       26257    795\n",
       "Edu_8                       26709    343\n",
       "HispanicOriginRaceRecode_2  26842    210\n",
       "HispanicOriginRaceRecode_3  26934    118\n",
       "HispanicOriginRaceRecode_4  26889    163\n",
       "HispanicOriginRaceRecode_5  26833    219\n",
       "HispanicOriginRaceRecode_6   9032  18020\n",
       "HispanicOriginRaceRecode_7  20813   6239\n",
       "HispanicOriginRaceRecode_8  26481    571\n",
       "Homicide_1                  17867   9185\n",
       "MaritalStatus_M             18190   8862\n",
       "MaritalStatus_S             15229  11823\n",
       "MaritalStatus_W             25388   1664\n",
       "PlaceOfInjury_2             26853    199\n",
       "PlaceOfInjury_3             27025     27\n",
       "PlaceOfInjury_4             23923   3129\n",
       "PlaceOfInjury_5             26081    971\n",
       "PlaceOfInjury_6             26978     74\n",
       "PlaceOfInjury_7             26911    141\n",
       "PlaceOfInjury_8             23127   3925\n",
       "PlaceOfInjury_9             25662   1390\n",
       "ResidentStatus_2            24260   2792\n",
       "ResidentStatus_3            26027   1025\n",
       "ResidentStatus_4            27024     28\n",
       "Sex                         23133   3919"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "freq_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
